package zttc.itat.user.util;

import java.sql.*;

public class DbUtil {
	public static Connection getConnection() throws SQLException, ClassNotFoundException{
		Connection conn=null;
		Class.forName("com.mysql.jdbc.Driver");
		//conn=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/itat_junit?user=root&password=liuhao");
		conn=DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/itat_hibernate", "root", "liuhao");
		return conn;
	}
	
	public static void close(Connection conn){
		if(conn!=null){
			try {
				conn.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	} 
	
	public static void close(PreparedStatement ps){
		if(ps!=null){
			try {
				ps.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	} 
	
	public static void close(ResultSet rs){
		if(rs!=null){
			try {
				rs.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	} 
}
